import React,{useImperativeHandle} from 'react'
import { useState } from 'react';
export default function Son(props) {
    const [sonName,setSonName] = useState('儿子名字')
    const changeName = () => {
      setSonName('你好')
      console.log(sonName,'sonName');
    }
    const logFunc = () => {
      console.log('Dayinle');
      
    }
    const getFather = () => {
      props.changeInfo( )
    }
    useImperativeHandle(props.ref,() => ({
      changeName,
      logFunc,
    }))
  return (
    <div>
        <div>父传过来的:{props.num}</div>
        子名字:{sonName}
        <button onClick={getFather}>调父</button>
    </div>
  )
}
